<?php

namespace app\common\model;

use think\Model;

class Admin extends Model
{

    /**
     * 判断是否是管理员
     * @param $user_id
     * @return array|false|\PDOStatement|string|Model
     */
    static function get_admin_by_user_id($user_id)
    {
        $s = new self();
        return $s->where('user_id',$user_id)->find();
    }

    /**
     * 新增管理员
     * @param $param
     * @return Admin
     */
    static function add_admin($param)
    {
        $admin = new self();
        $admin->user_id = $param['user_id'];
        $admin->created_time = date("Y-m-d H:i",time());
        $admin->save();
        return $admin;
    }

    /**
     * 取消设置管理员
     * @param $user_id
     */
    static function del_admin($user_id)
    {
        $s = new self();
        $seller = $s->where('user_id',$user_id)->find();
        $seller->delete();
    }
}
